#include <reg52.h>
#include "AT24C02.h"
#include "lcd1602.h"
#include "keyboard.h"  

bit input_flag, cmp_flag;
extern uchar input_psw[6];
extern uchar init_psw[6];

void main()
{  
    uchar i, value;
    
    lcd1602_init();
    lcd1602_disp_lst_char(0, 0, "Password:", 9);
    
    while(1)
    {    
        value = key_scan();
        
        if(value == 15)
        {
            input_flag = 1;
        
            if(input_flag == 1)
            {
                enter_psw(input_psw);
                cmp_flag = 1;
            }
            if(cmp_flag == 1)
            {
                cmp_psw(); 
            }
        }
        else if(value == 13)
        {
            change_psw();
        
            /*
                for(i = 0; i < 6; i++)
                {  
                    AT24C02_write(i, init_psw[i]);
                    delay_ms(10);
                }
                delay_ms(20);
             
            
                for(i = 0; i < 6; i++)
                {  
                    init_psw[i] = AT24C02_read(i);
                    delay_ms(10);
                }
                
                lcd1602_write_com(0xc0);
                for(i = 0; i < 6; i++)
                {
                    lcd1602_write_data(('0' + init_psw[i]));
                }
                */
                

           
        }
        
      
    }
}


    



